
/****** Object:  StoredProcedure [proc_Tataya_UserLoadByPrimaryKey]    Script Date: 7/30/2011 9:07:33 AM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_UserLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Username],
		[Password],
		[FullName],
		[CreatedDate],
		[Active]
	FROM [Tataya_User]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_UserLoadAll]    Script Date: 7/30/2011 9:07:33 AM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_UserLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Username],
		[Password],
		[FullName],
		[CreatedDate],
		[Active]
	FROM [Tataya_User]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_UserUpdate]    Script Date: 7/30/2011 9:07:33 AM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserUpdate];
GO

CREATE PROCEDURE [proc_Tataya_UserUpdate]
(
	@ID int,
	@Username varchar(20),
	@Password varchar(50),
	@FullName nvarchar(200),
	@CreatedDate datetime,
	@Active bit
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_User]
	SET
		[Username] = @Username,
		[Password] = @Password,
		[FullName] = @FullName,
		[CreatedDate] = @CreatedDate,
		[Active] = @Active
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_UserInsert]    Script Date: 7/30/2011 9:07:33 AM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserInsert];
GO

CREATE PROCEDURE [proc_Tataya_UserInsert]
(
	@ID int = NULL output,
	@Username varchar(20),
	@Password varchar(50),
	@FullName nvarchar(200),
	@CreatedDate datetime,
	@Active bit
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_User]
	(
		[Username],
		[Password],
		[FullName],
		[CreatedDate],
		[Active]
	)
	VALUES
	(
		@Username,
		@Password,
		@FullName,
		@CreatedDate,
		@Active
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_UserDelete]    Script Date: 7/30/2011 9:07:33 AM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserDelete];
GO

CREATE PROCEDURE [proc_Tataya_UserDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_User]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserDelete Error on Creation'
GO


